package org.example.chapter6.main;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.PlatformTransactionManager;

import javax.annotation.PostConstruct;

/**
 * @author CoderXshuai
 * @date 2020/7/28/0028 18:05
 */
@MapperScan(
        basePackages = "org.example.chapter6",
        annotationClass = Repository.class
)
@SpringBootApplication(scanBasePackages = "org.example.chapter6")
public class Chapter6Application {
    //注入事物管理器,它由Spring Boot自动生成
    @Autowired
    PlatformTransactionManager transactionManager;

    public static void main(String[] args) {
        SpringApplication.run(Chapter6Application.class, args);
    }

    //使用后初始化方法,观察自动生成的事物管理器
    @PostConstruct
    public void viewTransactionManager() {
        //启动前加入断点观测
        System.out.println(transactionManager.getClass().getName());
    }
}
